package game.savecameron;

import java.awt.Image;
import java.awt.Point;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javax.imageio.ImageIO;
import javax.swing.KeyStroke;
import ben.samplegame.rules.GravityRule;
import ben.samplegame.sprite.SampleEnemy;
import ben.samplegame.sprite.SamplePlayer;
import ben.samplegame.sprite.SpaceBackground;
import game.engine.GameLevel;
import game.engine.GameRule;
import game.sprite.PlayerSprite;
import game.sprite.Sprite;
import game.userinteraction.IControllable;
import game.userinteraction.UserInputHandler;

public class KvilleLevel extends GameLevel implements IControllable {

    public KvilleLevel (File levelInfo, List<GameRule> levelRules,
            UserInputHandler inputHandler) throws SecurityException, NoSuchMethodException {
        super(levelInfo, levelRules, inputHandler);
        temporaryCreation();
        inputHandler.add((SamplePlayer)getPlayer());
        inputHandler.add(this);
    }

    private void temporaryCreation () throws SecurityException, NoSuchMethodException {
        Image testBackground = null;
        try {
            testBackground = ImageIO.read(new File("src/ben/samplegame/blackhole_background.jpeg"));

        } catch (IOException e) {
        }
        KvilleBackground background = new KvilleBackground(testBackground, 600, 600, 0, 0);
        PlayerSprite player = new SamplePlayer(new Point(0,200), "", true);
      
        setBackground(background);
 
        setPlayer(player);
        ArrayList<Sprite> levelSprites = new ArrayList<Sprite>();
        levelSprites.add(player);
        levelSprites.add(new TarHeel(new Point(200, 500),"", true, player));
        levelSprites.add(new TarHeel(new Point(100, 500),"", true, player));
        levelSprites.add(new TarHeel(new Point(400, 500),"", true, player));
        levelSprites.add(new TarHeel(new Point(200, 300),"", true, player));
        setLevelSprites(levelSprites);
        ArrayList<GameRule> levelRules = new ArrayList<GameRule>();
        levelRules.add(new GravityRule(levelSprites, background));
        setLevelRules(levelRules);
    }

    @Override
    public void react (Set<KeyStroke> keyPresses) {
        System.out.println(keyPresses.size());
        for (KeyStroke a : keyPresses) {
            System.out.println(a);
        }
    }
}
